var myCirclePlayer;
var currItemNumber;
var sermonList = [
	"../AUDIO/2010/SUNDAY%20SCHOOL/03-21-10%20SUNDAY%20SCHOOL.mp3",
	"../AUDIO/2009/SUNDAY%20SCHOOL/04-05-09%20SUNDAY%20SCHOOL.mp3",
	"../AUDIO/2009/OTHER/04-05-09%20AM%20CLAYPOOL.mp3",
	"../AUDIO/2009/SUNDAY%20SCHOOL/03-22-09%20SUNDAY%20SCHOOL.mp3",
	"../AUDIO/2011/SUNDAY%20SCHOOL/04-10-2011%20SUNDAY%20SCHOOL.mp3",
	"../AUDIO/2009/SUNDAY%20SCHOOL/11-22-09%20SUNDAY%20SCHOOL%20BRO%20MARTINEZ-MISSIONARY%20TO%20BRAZIL.mp3",
	"../AUDIO/2009/SUNDAY%20SCHOOL/04-12-09%20SUNDAY%20SCHOOL.mp3",
	"../AUDIO/2010/SUNDAY%20SCHOOL/01-17-10%20SUNDAY%20SCHOOL-BRO%20SPILLMAN.mp3"
];

function selectItem(item) {
    if (0 <= currItemNumber && currItemNumber < sermonList.length) {
    	var currItem = document.getElementById("player-item-" + currItemNumber.toString());
        removeClass(currItem, 'bold');
        removeClass(currItem, 'colorPrimary-5');
        addClass(currItem, 'colorSecondary-a-2');
    }
    addClass(item, 'bold');
    addClass(item, 'colorPrimary-5');
    removeClass(item, 'colorSecondary-a-2');
    currItemNumber = parseInt(item.id.substr(item.id.lastIndexOf("-") + 1));
    myCirclePlayer.setMedia({
    	mp3: sermonList[currItemNumber]
    });
}

function playItem(item) {
    selectItem(item);
	myCirclePlayer.play();
}

$(document).ready(function(){
	myCirclePlayer = new CirclePlayer("#jquery_jplayer_1",
	{
	}, {
		supplied: "mp3",
		cssSelectorAncestor: "#cp_container_1",
		swfPath: "../Content/Javascript/jplayer/Jplayer.swf",
		wmode: "window",
		keyEnabled: true
	});

	for(var i = 0; i < sermonList.length; ++i){
		addClass(document.getElementById("player-item-" + i.toString()), 'colorSecondary-a-2');
	}

	selectItem(document.getElementById("player-item-0"));
});